package org.example.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.domain.Role;
import org.example.domain.User;

import java.util.List;

@Mapper
public interface RoleDao extends BaseMapper<Role> {

    @Select("select * from role")
    public List<Role> getAllRole();

    @Update("update user_role set role_id = #{roleId} where user_id = #{userId}")
    int updateUserRole(int userId, int roleId);

    @Select("select user_id from user_role where role_id = #{roleId}")
    List<Integer> getUsersByRoleId(int roleId);
}
